﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.IO;
using System.Collections;
using System.Data.SqlClient;
using System.Data;
using Stringx;
namespace ClassLibrary1
{
    
    public class StringConnection
    {
        private SqlConnection conn = null;
        private SqlDataAdapter adapter = null;
        private DataSet ds = null;
        public StringConnection(){}
        public void Setconnection()  
        {
            using (StreamReader sr = new StreamReader("sconnection.ini"))
            {
              conn = new SqlConnection( sr.ReadLine());
            }
        }
        public SqlDataAdapter SetAdapt()
        {
            adapter = new SqlDataAdapter();
            adapter.SelectCommand = new SqlCommand("select * from student", conn);
            SqlCommandBuilder asd = new SqlCommandBuilder(adapter);
            ds = new DataSet();
            adapter.Fill(ds);
            return adapter;
        }

        public DataSet ReturnDataset()
        {
            return ds;
        }

        public DataSet Add(Stringx.Stringxd sx)
        {
            DataRow rw = ds.Tables[0].NewRow();
            rw["编号"]=sx.studnumber;
            rw["姓名"] = sx.studname;
            ds.Tables[0].Rows.Add(rw);
            adapter.Update(ds);
            return ds;
           
        }

    }
}
